﻿@namespace BootstrapBlazor.Components
@inherits BootstrapInputBase<string>

@if (IsShowLabel)
{
    <BootstrapLabel required="@Required" for="@Id" ShowLabelTooltip="ShowLabelTooltip" Value="@DisplayText" />
}
<div class="@ClassString" @ref="AutoCompleteElement">
    <input @attributes="AdditionalAttributes" id="@Id" class="@ClassName" autocomplete="off" type="@Type" placeholder="@PlaceHolder" disabled="@Disabled" @bind-value="@CurrentValueAsString" @bind-value:event="oninput" @onblur="OnBlur" @onfocus="OnFocus" @onkeyup="OnKeyUp" @ref="FocusElement" />
    <i class="fa-fw fa-spin fa-solid fa-spinner"></i>
    <ul class="@DropdownMenuClassString">
        @if (FilterItems.Any())
        {
            @foreach (var item in FilterItems)
            {
                <li class="dropdown-item" @onmousedown="e => OnClickItem(item)">
                    @if (ItemTemplate == null)
                    {
                        <div>@item</div>
                    }
                    else
                    {
                        @ItemTemplate(item)
                    }
                </li>
            }
        }
        else
        {
            <li class="dropdown-item">@NoDataTip</li>
        }
    </ul>
</div>
